package com.appleyk;

import com.appleyk.service.PayService;
import java.util.ServiceLoader;

/**
 * <p>SPI(Service Provider Interface)机制测试,主要用于解耦，功能实现可插拔</p>
 *
 * @author appleyk
 * @version V.0.1.1
 * @blob https://blog.csdn.net/appleyk
 * @date created on  9:10 下午 2020/12/2
 */
public class MainTest {
    public static void main(String[] args) {
        ServiceLoader<PayService> services = ServiceLoader.load(PayService.class);
        for (PayService service : services) {
            System.out.println(service.getClass());
            service.pay();
        }
    }
}
